﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace Dycox.Reporting
{
    public class TextBlock : BlockElement
    {
        private string _text;

        [XmlAttribute("text")]
        public string Text
        {
            get { return _text; }
            set { _text = value; }
        }

        protected internal override System.Drawing.SizeF GetClientSize(RenderingContext context)
        {
            var size = ReportPaint.MeasureText(context, context.EvalString(_text), GetRuntimeStyle());
            return size;
        }

        protected internal override void Render(RenderingContext context)
        {
            RectangleF bounds = this.GetBounds(context);
            ElementStyle style = GetRuntimeStyle();

            ReportPaint.RenderBackground(context, bounds, style.Background);
            ReportPaint.DrawString(context, context.EvalString(Text), bounds, style);
            ReportPaint.RenderBorders(context, bounds, style.Border);

        }
    }
}
